package com.nbsaas.boot.customer.rest.convert;

import com.nbsaas.boot.customer.data.entity.CustomerAddress;
import com.nbsaas.boot.customer.api.domain.response.CustomerAddressResponse;

import com.nbsaas.boot.utils.BeanDataUtils;
import com.nbsaas.boot.rest.api.Converter;
/**
* 实体对象转化成响应对象
*/

public class CustomerAddressResponseConvert  implements Converter<CustomerAddressResponse,CustomerAddress> {

    @Override
    public CustomerAddressResponse convert(CustomerAddress source) {
        CustomerAddressResponse  result = new  CustomerAddressResponse();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getArea()!=null){
                        result.setArea(source.getArea().getId());
                    }
                    if(source.getCity()!=null){
                        result.setCity(source.getCity().getId());
                    }
                    if(source.getCustomer()!=null){
                        result.setCustomerName(source.getCustomer().getName());
                    }
                    if(source.getProvince()!=null){
                        result.setProvince(source.getProvince().getId());
                    }
                    if(source.getCity()!=null){
                        result.setCityName(source.getCity().getName());
                    }
                    if(source.getArea()!=null){
                        result.setAreaName(source.getArea().getName());
                    }
                    if(source.getStoreState()!=null){
                        result.setStoreStateName(String.valueOf(source.getStoreState()));
                    }
                    if(source.getProvince()!=null){
                        result.setProvinceName(source.getProvince().getName());
                    }
                    if(source.getCustomer()!=null){
                        result.setCustomer(source.getCustomer().getId());
                    }
        return result;
    }

}

